<a href="<?php echo( base_url() ); ?>cmb/member_reports/download_banquet_report/<?php echo( $urlKey ); ?>/" target="_self">Download Data</a>
<?php
	Includes::IncludeFile( Includes::$FORM );
	Includes::IncludeFile( Includes::$SPACER );
	
	$curdatetime = time();
	
	$curdate = date('l, F jS, Y', $curdatetime);
	Form::OpenFormItemSummary('Date:', 50);
		echo( form_label($curdate, 'numrecs', 'style="width: 50px;" ') );
	Form::CloseFormItem();

	$curtime = date('h:i:s A', $curdatetime);
	Form::OpenFormItemSummary('Time:', 50);
		echo( form_label($curtime, 'numrecs', 'style="width: 50px;" ') );
	Form::CloseFormItem();
	
	Form::OpenFormItemSummary('Number of search results:', 260);
		echo( form_label(count($bqinfo), 'numrecs', 'style="width: 20px;" ') );
	Form::CloseFormItem();
	echo('<hr style="width:50%; size:10; color:#0000FF;" align="left" />');
	
	Spacer::Render(0, 20);
		
?>
<table border="1">
	<?php
		if (count($bqinfo) > 0)
		{
			$i = 0;
			//Create header
			echo('<th>First&nbspName</th>');
			echo('<th>Last&nbspName</th>');
			echo('<th>Email</th>');
			echo('<th>Phone</th>');
			echo('<th>Address</th>');
			echo('<th>City</th>');
			echo('<th>State</th>');
			echo('<th>Zip</th>');
			echo('<th>#Persons</th>');
			echo('<th>#Adults</th>');
			echo('<th>#Children</th>');
            echo('<th>$Registration</th>');
            echo('<th>$Donation</th>');
            echo('<th>$Teacher&nbspDiscount</th>');
			echo('<th>$Total</th>');
			echo('<th>Pay&nbspStatus</th>');
            echo('<th>Date&nbspCreated</th>');

			$tota = 0;
			$totc = 0;
			$totp = 0;
			$totamount = 0;
            $totreg = 0;
			$totdonation = 0;
            $totdisc = 0;
			foreach( $bqinfo as $bqrec)
			{
				if ($i % 2 != 0)
				{
					$rowColor = "#e0ffff";
				}
				else
				{
					$rowColor = "#ffffff";
				}

				$totpersons = intval($bqrec['numadultreg']) + intval($bqrec['numchildreg']);
				
				echo('<tr bgcolor="'.$rowColor.'">');
                echo('<td>'.$bqrec['firstname'].'</td>');
                echo('<td>'.$bqrec['lastname'].'</td>');
                echo('<td>'.$bqrec['email'].'</td>');
                echo('<td>'.$bqrec['phone'].'</td>');
                echo('<td>'.$bqrec['address'].'</td>');
                echo('<td>'.$bqrec['city'].'</td>');
                echo('<td>'.$bqrec['state'].'</td>');
                echo('<td>'.$bqrec['zip'].'</td>');
                echo('<td>'.$totpersons.'</td>');
                echo('<td>'.$bqrec['numadultreg'].'</td>');
                echo('<td>'.$bqrec['numchildreg'].'</td>');
                echo('<td>$'.$bqrec['reg_fee'].'</td>');
                echo('<td>$'.$bqrec['donation_amount'].'</td>');
                echo('<td>($'.$bqrec['teacher_discount'].')</td>');
                echo('<td>$'.$bqrec['amount_paid'].'</td>');
                echo('<td>'.$bqrec['paystatus'].'</td>');
                echo('<td>'.$bqrec['date_created'].'</td>');
                echo('</tr>');
							
				$tota += intval($bqrec['numadultreg']);
				$totc += intval($bqrec['numchildreg']);
				$totp += $totpersons;
				$totamount += floatval($bqrec['amount_paid']);
                $totreg += floatval($bqrec['reg_fee']);
				$totdonation += floatval($bqrec['donation_amount']);
                $totdisc += floatval($bqrec['teacher_discount']);
				
				$i++;
			}

			//Show total
			echo('<th><b>Total</b></th>');
			echo('<th></th>');
			echo('<th></th>');
			echo('<th></th>');
			echo('<th></th>');
			echo('<th></th>');
			echo('<th></th>');
			echo('<th></th>');
			echo('<th>'.$totp.'</th>');
			echo('<th>'.$tota.'</th>');
			echo('<th>'.$totc.'</th>');
            echo('<th>$'.$totreg.'</th>');
			echo('<th>$'.$totdonation.'</th>');
            echo('<th>$'.$totdisc.'</th>');
            echo('<th>$'.$totamount.'</th>');
			echo('<th></th>');
			echo('<th></th>');
		}
		else
			echo "No results returned";
	?>
</table>
